package cn.crce.cloud9.simple;

import javax.swing.*;
import java.awt.*;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Rectangle2D;

/**
 * @author OnCloud9
 * @description
 * @project NRCE-TEST
 * @date 2022年09月10日 上午 10:25
 */
public class Case35 {
    public static void main(String[] args) {
        DrawFrame frame = new DrawFrame();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//*********Found**********
        frame.setVisible(true);
    }

}

//*********Found**********
class DrawFrame extends JFrame {
    public DrawFrame() {
        setTitle("千里共婵娟");
        setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);
        DrawPanel panel = new DrawPanel();
//*********Found**********
        Container contentPane = this.getContentPane();
//*********Found**********
        contentPane.add(panel);
    }

    public static final int DEFAULT_WIDTH = 400;
    public static final int DEFAULT_HEIGHT = 240;
}

//*********Found**********
class DrawPanel extends JPanel {
    public void paintComponent(Graphics g) {
        super.paintComponent(g);
        Graphics2D g2 = (Graphics2D) g;
        double l = 0;
        double r = 0;
        double w = 400;
        double h = 400;
        Rectangle2D re = new Rectangle2D.Double(l, r, w, h);
        g2.setPaint(Color.BLUE);
        g2.fill(re);
        double leftX = 50;
        double topY = 50;
        double width = 50;
        double height = 50;
        Rectangle2D rect = new Rectangle2D.Double(leftX, topY, width, height);
        Ellipse2D ellipse = new Ellipse2D.Double();
        ellipse.setFrame(rect);
        g2.setPaint(Color.YELLOW);
        g2.fill(ellipse);
    }
}